.include "record-def.s"
.include "linux.s"

# 目的：本函数将一条记录写入给定文件描述符
#
# 输入：文件描述符和缓冲区
#
# 输出：本函数产生的状态码

# 栈局部变量
.equ ST_WRITE_BUFFER, 16
.equ ST_FILEDS, 24

.section .text
.globl write_record
.type write_record, @function
write_record:
    push    %rbp
    mov     %rsp, %rbp
    
    push    %rbx
    mov     $SYS_WRITE, %rax
    mov     ST_FILEDS(%rbp), %rbx
    mov     ST_WRITE_BUFFER(%rbp), %rcx
    mov     $RECORD_SIZE, %rdx
    int     $LINUX_SYSCALL

    pop     %rbx

    mov     %rbp, %rsp
    pop     %rbp
    ret
